package com.smbss.service.impl;

import com.smbss.entity.User;
import com.smbss.mapper.UserMapper;
import com.smbss.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 用户
 */
@Service("userService")
@Transactional
public class UserServiceImpl implements UserService {

    /**
     *  用户
     */
    @Autowired
    private UserMapper userMapper;

    public List<User> findByAll() {
        return userMapper.findUserAll();
    }

    public int insert(User user) {
        return this.userMapper.insert(user);
    }

    public int insetByTransactional(User user) {
        int code = this.userMapper.insert(user);
        code = code / 0; //故意报错，就是为了测试回滚
        return code;
    }
}
